import request from '@/utils/request';
import { AUTH_BASIC_CODE, ILA_CLIENT_TYPE } from '@/common/constant';

export interface LoginParamsType {
  userName: string;
  password: string;
  mobile: string;
  captcha: string;
}

const scope = 'server'

export async function fakeAccountLogin(params: LoginParamsType) {
  // @ts-ignore
  const grant_type = 'password'
  return request('/auth/oauth/token', {
    // @ts-ignore
    headers: {
      isToken: false,
      'Authorization': AUTH_BASIC_CODE,
      'ILA-Access-type': ILA_CLIENT_TYPE
    },
    method: 'POST',
    params: Object.assign(params, {grant_type, scope})
  });
}

export async function getFakeCaptcha(mobile: string) {
  return request(`/api/login/captcha?mobile=${mobile}`);
}
